﻿using Dapper;
using Dapper_Core.Basic;
using Dapper_Core.Table;
using System;
using System.Collections.Generic;
using System.Text;

namespace Dapper_Core.DAL.Impl
{
    public class WorkflowNodeSyncDetail : AbstractSyncDetail
    {
        public override void SyncDetail(BaseModel model, Sys_TableRelation relation)
        {
            base.SyncDetail(model, relation);

            BaseRepository<WorkflowNode> repository = new BaseRepository<WorkflowNode>();
            string where = "where 1=1";
            DynamicParameters parameters = new DynamicParameters();
            where += $" and {relation.ToProperty}=@{relation.ToProperty}";
            parameters.Add(relation.ToProperty, fromPropertyValue);
            IEnumerable<WorkflowNode> list = repository.GetList(where, parameters);
            model.SetFieldValue(relation.FromDetailProperty, list);
        }
    }
}
